Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bytebuffer

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bytebuffer

The swiss army knife for binary data in JavaScript.

  • 5.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
389K
increased by45.34%
Maintainers
1
Weekly downloads
 
Created

What is bytebuffer?

The bytebuffer npm package is a utility for working with binary data in JavaScript. It provides a comprehensive API for reading and writing various data types to and from byte buffers, making it useful for tasks such as serialization, deserialization, and network communication.

What are bytebuffer's main functionalities?

Creating a ByteBuffer

This feature allows you to create a new ByteBuffer instance. ByteBuffers are used to manage binary data efficiently.

const ByteBuffer = require('bytebuffer');
const bb = new ByteBuffer();

Writing Data to a ByteBuffer

This feature allows you to write various data types to a ByteBuffer. In this example, an integer and a float are written to the buffer.

const ByteBuffer = require('bytebuffer');
const bb = new ByteBuffer();
bb.writeInt32(123456);
bb.writeFloat32(3.14);

Reading Data from a ByteBuffer

This feature allows you to read various data types from a ByteBuffer. In this example, an integer and a float are read from the buffer after writing.

const ByteBuffer = require('bytebuffer');
const bb = new ByteBuffer();
bb.writeInt32(123456);
bb.writeFloat32(3.14);
bb.flip();
const intVal = bb.readInt32();
const floatVal = bb.readFloat32();

Handling Endianness

This feature allows you to specify the endianness (byte order) of the ByteBuffer. In this example, the buffer is set to little-endian mode.

const ByteBuffer = require('bytebuffer');
const bb = new ByteBuffer(ByteBuffer.LITTLE_ENDIAN);
bb.writeInt32(123456);
bb.flip();
const intVal = bb.readInt32();

Converting ByteBuffer to ArrayBuffer

This feature allows you to convert a ByteBuffer to an ArrayBuffer, which can be useful for interoperability with other APIs that use ArrayBuffers.

const ByteBuffer = require('bytebuffer');
const bb = new ByteBuffer();
bb.writeInt32(123456);
const arrayBuffer = bb.toArrayBuffer();

Other packages similar to bytebuffer

Keywords

FAQs

Package last updated on 12 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc